package com.ljkj.cordial.chat.util;

import android.graphics.Bitmap;
import android.util.LruCache;

public class LruCacheUtil {
    private static LruCacheUtil mLruCacheUtil;
    private LruCache<String, Bitmap> mLruCache;

    public static LruCacheUtil getInstance() {

        if (mLruCacheUtil == null) {
            synchronized (LruCacheUtil.class) {
                if (mLruCacheUtil == null) {
                    mLruCacheUtil = new LruCacheUtil();
                }
            }
        }
        return mLruCacheUtil;

    }

    public LruCacheUtil() {//大小自己根据情况写
        mLruCache = new LruCache(3 * 1024);
    }

    public Bitmap getBitmap(String url) {
        return mLruCache.get(url);
    }

    public void putBitmap(String url, Bitmap bitmap) {
        mLruCache.put(url, bitmap);
    }
}
